package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

@Controller
public class OrderController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    /**
     * 确定订单
     * 点击“结算”时的控制器： window.location.href = 'http://order.gmall.com/trade.html'
     */
    @GetMapping("trade.html")
    public String trade(Model model) {

        // 远程调用 获取订单页面需要的数据
        Result<Map<String, Object>> result = orderFeignClient.trade();

        // 保存页面需要的数据 OrderApiController.trade(){...return Result.ok(map);}
        model.addAllAttributes(result.getData());

        return "order/trade";
    }
}
